home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / programming / aros / exec / addsemaphore.c < prev    next >
C/C++ Source or Header  |  1996-09-12  |  2KB  |  74 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: addsemaphore.c,v 1.4 1996/08/13 13:55:56 digulla Exp $
  4.     $Log: addsemaphore.c,v $
  5.     Revision 1.4  1996/08/13 13:55:56  digulla
  6.     Replaced __AROS_LA by __AROS_LHA
  7.     Replaced some __AROS_LH*I by __AROS_LH*
  8.     Sorted and added includes
  9.  
  10.     Revision 1.3  1996/08/01 17:41:03  digulla
  11.     Added standard header for all files
  12.  
  13.     Desc:
  14.     Lang: english
  15. */
  16. #include "exec_intern.h"
  17.  
  18. /*****************************************************************************
  19.  
  20.     NAME */
  21.     #include <exec/semaphores.h>
  22.     #include <clib/exec_protos.h>
  23.  
  24.     __AROS_LH1(void, AddSemaphore,
  25.  
  26. /*  SYNOPSIS */
  27.     __AROS_LHA(struct SignalSemaphore *, sigSem, A1),
  28.  
  29. /*  LOCATION */
  30.     struct ExecBase *, SysBase, 100, Exec)
  31.  
  32. /*  FUNCTION
  33.     Adds a semaphore to the system public semaphore list. Since the
  34.     semaphore gets initialized by this function it must be free at
  35.     this time. Also the ln_Name field must be set.
  36.  
  37.     INPUTS
  38.     sigSem - Pointer to semaphore structure
  39.  
  40.     RESULT
  41.  
  42.     NOTES
  43.     Semaphores are shared between the tasks that use them and must
  44.     therefore lie in public (or at least shared) memory.
  45.  
  46.     EXAMPLE
  47.  
  48.     BUGS
  49.  
  50.     SEE ALSO
  51.  
  52.     INTERNALS
  53.  
  54.     HISTORY
  55.  
  56. *****************************************************************************/
  57. {
  58.     __AROS_FUNC_INIT
  59.  
  60.     /* Intialize semaphore */
  61.     sigSem->ss_Link.ln_Type=NT_SIGNALSEM;
  62.     InitSemaphore(sigSem);
  63.  
  64.     /* Arbitrate for the semaphore list */
  65.     Forbid();
  66.     /* Add the semaphore */
  67.     Enqueue(&SysBase->SemaphoreList,&sigSem->ss_Link);
  68.  
  69.     /* All done. */
  70.     Permit();
  71.     __AROS_FUNC_EXIT
  72. } /* AddSemaphore */
  73.  
  74.